.class Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;
.super Lorg/jboss/netty/channel/AbstractChannel;
.source "NioDatagramChannel.java"

# interfaces
.implements Lorg/jboss/netty/channel/socket/DatagramChannel;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel$WriteTask;,
        Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel$WriteRequestQueue;
    }
.end annotation


# instance fields
.field private final config:Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;

.field currentWriteBuffer:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;

.field currentWriteEvent:Lorg/jboss/netty/channel/MessageEvent;

.field private final datagramChannel:Ljava/nio/channels/DatagramChannel;

.field final highWaterMarkCounter:Ljava/util/concurrent/atomic/AtomicInteger;

.field inWriteNowLoop:Z

.field final interestOpsLock:Ljava/lang/Object;

.field private volatile localAddress:Ljava/net/InetSocketAddress;

.field volatile remoteAddress:Ljava/net/InetSocketAddress;

.field final worker:Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;

.field final writeBufferQueue:Ljava/util/Queue;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Queue",
            "<",
            "Lorg/jboss/netty/channel/MessageEvent;",
            ">;"
        }
    .end annotation
.end field

.field final writeBufferSize:Ljava/util/concurrent/atomic/AtomicInteger;

.field final writeLock:Ljava/lang/Object;

.field writeSuspended:Z

.field final writeTask:Ljava/lang/Runnable;

.field final writeTaskInTaskQueue:Ljava/util/concurrent/atomic/AtomicBoolean;


# direct methods
.method constructor <init>(Lorg/jboss/netty/channel/ChannelFactory;Lorg/jboss/netty/channel/ChannelPipeline;Lorg/jboss/netty/channel/ChannelSink;Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;)V
    .locals 2
    .parameter "factory"
    .parameter "pipeline"
    .parameter "sink"
    .parameter "worker"

    .prologue
    .line 119
    const/4 v0, 0x0

    invoke-direct {p0, v0, p1, p2, p3}, Lorg/jboss/netty/channel/AbstractChannel;-><init>(Lorg/jboss/netty/channel/Channel;Lorg/jboss/netty/channel/ChannelFactory;Lorg/jboss/netty/channel/ChannelPipeline;Lorg/jboss/netty/channel/ChannelSink;)V

    .line 68
    new-instance v0, Ljava/lang/Object;

    invoke-direct {v0}, Ljava/lang/Object;-><init>()V

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->interestOpsLock:Ljava/lang/Object;

    .line 73
    new-instance v0, Ljava/lang/Object;

    invoke-direct {v0}, Ljava/lang/Object;-><init>()V

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeLock:Ljava/lang/Object;

    .line 78
    new-instance v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel$WriteTask;

    invoke-direct {v0, p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel$WriteTask;-><init>(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeTask:Ljava/lang/Runnable;

    .line 83
    new-instance v0, Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicBoolean;-><init>()V

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeTaskInTaskQueue:Ljava/util/concurrent/atomic/AtomicBoolean;

    .line 88
    new-instance v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel$WriteRequestQueue;

    invoke-direct {v0, p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel$WriteRequestQueue;-><init>(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeBufferQueue:Ljava/util/Queue;

    .line 94
    new-instance v0, Ljava/util/concurrent/atomic/AtomicInteger;

    invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicInteger;-><init>()V

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeBufferSize:Ljava/util/concurrent/atomic/AtomicInteger;

    .line 99
    new-instance v0, Ljava/util/concurrent/atomic/AtomicInteger;

    invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicInteger;-><init>()V

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->highWaterMarkCounter:Ljava/util/concurrent/atomic/AtomicInteger;

    .line 120
    iput-object p4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->worker:Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;

    .line 121
    invoke-direct {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->openNonBlockingChannel()Ljava/nio/channels/DatagramChannel;

    move-result-object v0

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->datagramChannel:Ljava/nio/channels/DatagramChannel;

    .line 122
    new-instance v0, Lorg/jboss/netty/channel/socket/nio/DefaultNioDatagramChannelConfig;

    iget-object v1, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->datagramChannel:Ljava/nio/channels/DatagramChannel;

    invoke-virtual {v1}, Ljava/nio/channels/DatagramChannel;->socket()Ljava/net/DatagramSocket;

    move-result-object v1

    invoke-direct {v0, v1}, Lorg/jboss/netty/channel/socket/nio/DefaultNioDatagramChannelConfig;-><init>(Ljava/net/DatagramSocket;)V

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->config:Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;

    .line 124
    invoke-static {p0}, Lorg/jboss/netty/channel/Channels;->fireChannelOpen(Lorg/jboss/netty/channel/Channel;)V

    .line 125
    return-void
.end method

.method private openNonBlockingChannel()Ljava/nio/channels/DatagramChannel;
    .locals 4

    .prologue
    .line 129
    :try_start_0
    invoke-static {}, Ljava/nio/channels/DatagramChannel;->open()Ljava/nio/channels/DatagramChannel;

    move-result-object v0

    .line 130
    .local v0, channel:Ljava/nio/channels/DatagramChannel;
    const/4 v2, 0x0

    invoke-virtual {v0, v2}, Ljava/nio/channels/DatagramChannel;->configureBlocking(Z)Ljava/nio/channels/SelectableChannel;
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    .line 131
    return-object v0

    .line 132
    .end local v0           #channel:Ljava/nio/channels/DatagramChannel;
    :catch_0
    move-exception v1

    .line 133
    .local v1, e:Ljava/io/IOException;
    new-instance v2, Lorg/jboss/netty/channel/ChannelException;

    const-string v3, "Failed to open a DatagramChannel."

    invoke-direct {v2, v3, v1}, Lorg/jboss/netty/channel/ChannelException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v2
.end method


# virtual methods
.method public bridge synthetic getConfig()Lorg/jboss/netty/channel/ChannelConfig;
    .locals 1

    .prologue
    .line 47
    invoke-virtual {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getConfig()Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;

    move-result-object v0

    return-object v0
.end method

.method public bridge synthetic getConfig()Lorg/jboss/netty/channel/socket/DatagramChannelConfig;
    .locals 1

    .prologue
    .line 47
    invoke-virtual {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getConfig()Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;

    move-result-object v0

    return-object v0
.end method

.method public getConfig()Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;
    .locals 1

    .prologue
    .line 179
    iget-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->config:Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;

    return-object v0
.end method

.method getDatagramChannel()Ljava/nio/channels/DatagramChannel;
    .locals 1

    .prologue
    .line 183
    iget-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->datagramChannel:Ljava/nio/channels/DatagramChannel;

    return-object v0
.end method

.method public getInterestOps()I
    .locals 5

    .prologue
    .line 188
    invoke-virtual {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->isOpen()Z

    move-result v4

    if-nez v4, :cond_0

    .line 189
    const/4 v1, 0x4

    .line 214
    :goto_0
    return v1

    .line 192
    :cond_0
    invoke-virtual {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getRawInterestOps()I

    move-result v1

    .line 193
    .local v1, interestOps:I
    iget-object v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeBufferSize:Ljava/util/concurrent/atomic/AtomicInteger;

    invoke-virtual {v4}, Ljava/util/concurrent/atomic/AtomicInteger;->get()I

    move-result v3

    .line 194
    .local v3, writeBufferSize:I
    if-eqz v3, :cond_4

    .line 195
    iget-object v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->highWaterMarkCounter:Ljava/util/concurrent/atomic/AtomicInteger;

    invoke-virtual {v4}, Ljava/util/concurrent/atomic/AtomicInteger;->get()I

    move-result v4

    if-lez v4, :cond_2

    .line 196
    invoke-virtual {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getConfig()Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;

    move-result-object v4

    invoke-interface {v4}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;->getWriteBufferLowWaterMark()I

    move-result v2

    .line 197
    .local v2, lowWaterMark:I
    if-lt v3, v2, :cond_1

    .line 198
    or-int/lit8 v1, v1, 0x4

    goto :goto_0

    .line 200
    :cond_1
    and-int/lit8 v1, v1, -0x5

    goto :goto_0

    .line 203
    .end local v2           #lowWaterMark:I
    :cond_2
    invoke-virtual {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getConfig()Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;

    move-result-object v4

    invoke-interface {v4}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;->getWriteBufferHighWaterMark()I

    move-result v0

    .line 204
    .local v0, highWaterMark:I
    if-lt v3, v0, :cond_3

    .line 205
    or-int/lit8 v1, v1, 0x4

    goto :goto_0

    .line 207
    :cond_3
    and-int/lit8 v1, v1, -0x5

    goto :goto_0

    .line 211
    .end local v0           #highWaterMark:I
    :cond_4
    and-int/lit8 v1, v1, -0x5

    goto :goto_0
.end method

.method public getLocalAddress()Ljava/net/InetSocketAddress;
    .locals 4

    .prologue
    .line 138
    iget-object v1, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->localAddress:Ljava/net/InetSocketAddress;

    .line 139
    .local v1, localAddress:Ljava/net/InetSocketAddress;
    if-nez v1, :cond_0

    .line 141
    :try_start_0
    iget-object v3, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->datagramChannel:Ljava/nio/channels/DatagramChannel;

    invoke-virtual {v3}, Ljava/nio/channels/DatagramChannel;->socket()Ljava/net/DatagramSocket;

    move-result-object v3

    invoke-virtual {v3}, Ljava/net/DatagramSocket;->getLocalSocketAddress()Ljava/net/SocketAddress;

    move-result-object v3

    move-object v0, v3

    check-cast v0, Ljava/net/InetSocketAddress;

    move-object v1, v0

    iput-object v1, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->localAddress:Ljava/net/InetSocketAddress;
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0

    :cond_0
    move-object v3, v1

    .line 148
    :goto_0
    return-object v3

    .line 143
    :catch_0
    move-exception v2

    .line 145
    .local v2, t:Ljava/lang/Throwable;
    const/4 v3, 0x0

    goto :goto_0
.end method

.method public bridge synthetic getLocalAddress()Ljava/net/SocketAddress;
    .locals 1

    .prologue
    .line 47
    invoke-virtual {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getLocalAddress()Ljava/net/InetSocketAddress;

    move-result-object v0

    return-object v0
.end method

.method getRawInterestOps()I
    .locals 1

    .prologue
    .line 218
    invoke-super {p0}, Lorg/jboss/netty/channel/AbstractChannel;->getInterestOps()I

    move-result v0

    return v0
.end method

.method public getRemoteAddress()Ljava/net/InetSocketAddress;
    .locals 4

    .prologue
    .line 152
    iget-object v1, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->remoteAddress:Ljava/net/InetSocketAddress;

    .line 153
    .local v1, remoteAddress:Ljava/net/InetSocketAddress;
    if-nez v1, :cond_0

    .line 155
    :try_start_0
    iget-object v3, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->datagramChannel:Ljava/nio/channels/DatagramChannel;

    invoke-virtual {v3}, Ljava/nio/channels/DatagramChannel;->socket()Ljava/net/DatagramSocket;

    move-result-object v3

    invoke-virtual {v3}, Ljava/net/DatagramSocket;->getRemoteSocketAddress()Ljava/net/SocketAddress;

    move-result-object v3

    move-object v0, v3

    check-cast v0, Ljava/net/InetSocketAddress;

    move-object v1, v0

    iput-object v1, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->remoteAddress:Ljava/net/InetSocketAddress;
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0

    :cond_0
    move-object v3, v1

    .line 162
    :goto_0
    return-object v3

    .line 157
    :catch_0
    move-exception v2

    .line 159
    .local v2, t:Ljava/lang/Throwable;
    const/4 v3, 0x0

    goto :goto_0
.end method

.method public bridge synthetic getRemoteAddress()Ljava/net/SocketAddress;
    .locals 1

    .prologue
    .line 47
    invoke-virtual {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getRemoteAddress()Ljava/net/InetSocketAddress;

    move-result-object v0

    return-object v0
.end method

.method public isBound()Z
    .locals 1

    .prologue
    .line 166
    invoke-virtual {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->isOpen()Z

    move-result v0

    if-eqz v0, :cond_0

    iget-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->datagramChannel:Ljava/nio/channels/DatagramChannel;

    invoke-virtual {v0}, Ljava/nio/channels/DatagramChannel;->socket()Ljava/net/DatagramSocket;

    move-result-object v0

    invoke-virtual {v0}, Ljava/net/DatagramSocket;->isBound()Z

    move-result v0

    if-eqz v0, :cond_0

    const/4 v0, 0x1

    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public isConnected()Z
    .locals 1

    .prologue
    .line 170
    iget-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->datagramChannel:Ljava/nio/channels/DatagramChannel;

    invoke-virtual {v0}, Ljava/nio/channels/DatagramChannel;->isConnected()Z

    move-result v0

    return v0
.end method

.method public joinGroup(Ljava/net/InetAddress;)V
    .locals 1
    .parameter "multicastAddress"

    .prologue
    .line 322
    new-instance v0, Ljava/lang/UnsupportedOperationException;

    invoke-direct {v0}, Ljava/lang/UnsupportedOperationException;-><init>()V

    throw v0
.end method

.method public joinGroup(Ljava/net/InetSocketAddress;Ljava/net/NetworkInterface;)V
    .locals 1
    .parameter "multicastAddress"
    .parameter "networkInterface"

    .prologue
    .line 327
    new-instance v0, Ljava/lang/UnsupportedOperationException;

    invoke-direct {v0}, Ljava/lang/UnsupportedOperationException;-><init>()V

    throw v0
.end method

.method public leaveGroup(Ljava/net/InetAddress;)V
    .locals 1
    .parameter "multicastAddress"

    .prologue
    .line 331
    new-instance v0, Ljava/lang/UnsupportedOperationException;

    invoke-direct {v0}, Ljava/lang/UnsupportedOperationException;-><init>()V

    throw v0
.end method

.method public leaveGroup(Ljava/net/InetSocketAddress;Ljava/net/NetworkInterface;)V
    .locals 1
    .parameter "multicastAddress"
    .parameter "networkInterface"

    .prologue
    .line 336
    new-instance v0, Ljava/lang/UnsupportedOperationException;

    invoke-direct {v0}, Ljava/lang/UnsupportedOperationException;-><init>()V

    throw v0
.end method

.method protected setClosed()Z
    .locals 1

    .prologue
    .line 175
    invoke-super {p0}, Lorg/jboss/netty/channel/AbstractChannel;->setClosed()Z

    move-result v0

    return v0
.end method

.method setRawInterestOpsNow(I)V
    .locals 0
    .parameter "interestOps"

    .prologue
    .line 222
    invoke-super {p0, p1}, Lorg/jboss/netty/channel/AbstractChannel;->setInterestOpsNow(I)V

    .line 223
    return-void
.end method

.method public write(Ljava/lang/Object;Ljava/net/SocketAddress;)Lorg/jboss/netty/channel/ChannelFuture;
    .locals 1
    .parameter "message"
    .parameter "remoteAddress"

    .prologue
    .line 227
    if-eqz p2, :cond_0

    invoke-virtual {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getRemoteAddress()Ljava/net/InetSocketAddress;

    move-result-object v0

    invoke-virtual {p2, v0}, Ljava/lang/Object;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_1

    .line 228
    :cond_0
    const/4 v0, 0x0

    invoke-super {p0, p1, v0}, Lorg/jboss/netty/channel/AbstractChannel;->write(Ljava/lang/Object;Ljava/net/SocketAddress;)Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v0

    .line 230
    :goto_0
    return-object v0

    :cond_1
    invoke-super {p0, p1, p2}, Lorg/jboss/netty/channel/AbstractChannel;->write(Ljava/lang/Object;Ljava/net/SocketAddress;)Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v0

    goto :goto_0
.end method
